package scene.shape.geometry;

import java.util.ArrayList;
import java.util.List;

import scene.shape.BoundingBox;
import scene.shape.Shape;


public class Geometry {
	
	protected String name;
	protected Shape shape;
	protected List<Primitive> primitiveList;
	
	public Geometry(){
		this.name = "";
	}
	
	public Geometry(String name){
		this.name = name;
		this.primitiveList = new ArrayList<Primitive>();
	}
	
	public Geometry(String name, List<Primitive> primitives){
		this.name = name;
		this.primitiveList = primitives;
	}
	
	public String getName() {
		return this.name;
	}
	
	public void setShape(Shape s){
		this.shape = s;
		for(Primitive p : primitiveList){
			p.setShape(s);
		}
	}
	
	public void addPrimitive(Primitive p){
		primitiveList.add(p);
	}
	
	public void addAllPrimitives(List<Primitive> primitiveList){
		this.primitiveList.addAll(primitiveList);
	}
	
	public void setPrimitiveList(List<Primitive> primitiveList){
		this.primitiveList = primitiveList;
	}
	
	public List<Primitive> getPrimitiveList(){
		return primitiveList;
	}
	
	public BoundingBox getBoundingBox(){
		BoundingBox b = null;
		for(Primitive p : primitiveList){
			b = BoundingBox.merge(p.getBoundingBox(), b);
		}
		return b;
	}
}
